<%-- 
    Document   : EmployeeClicked
    Created on : Dec 7, 2011, 2:35:28 AM
    Author     : Michael
--%>

<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% if(session.getAttribute("LoggedIn")==null)
       {
    response.sendRedirect("index.html");
    return;
        }

%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Employee Info</title>
        <script type="text/javascript">
            function button_updateInfo()
            {
            document.employeeInfo.submit();
            }
        </script>
    </head>
    <body>
        <h1>Edit Employee</h1>
            <% 
        Connection conn = new DBClasses.GetConnection().getConnection();
        session.setAttribute("EmployeeID", request.getParameter("EMP"));
        try
        {
           Statement stmt = conn.createStatement();
           String query = "SELECT * FROM employees WHERE EmployeeID='" + request.getParameter("EMP") + "'";
           ResultSet rs = stmt.executeQuery(query);
           
           if(!rs.next())
               response.sendRedirect("index.html");
    %>
   <table  width="400" border="0">
    <tr>
    <td id="profiletable" align="right" valign="top">
        <form style="padding-right: 150px;" name="employeeInfo" id="employeeInfo" action="employeeInfo.jsp" method="post">
        <label>SSN: </label>
        <input type="text" name="SSN" maxlength="9" value="<%=rs.getInt("SSN")%>" /><br />
        
        <label>First Name: </label> 
        <input type="text" name="FirstName" maxlength="50" value="<%=rs.getString("Firstname")%>" /><br />
        
        <label>Last Name: </label>
        <input type="text" name="LastName" maxlength="50" value="<%=rs.getString("Lastname")%>" /><br />
        
        <label>Address: </label>
        <input type="text" name="Address" maxlength="100" value="<%=rs.getString("Address")%>" /><br />
        
        <label>City: </label>
        <input type="text" name="City" maxlength="20" value="<%=rs.getString("City")%>" /><br />
        
        <label>State: </label>
        <input type="text" name="State" maxlength="2" value="<%=rs.getString("State")%>" /><br />
        
        <label>Zip: </label>
        <input type="text" name="ZipCode" maxlength="5" value="<%=rs.getString("ZipCode")%>" /><br />
        
        <label>Telephone: </label>
        <input type="text" name="Telephone" maxlength="10" value="<%=rs.getString("Telephone")%>" /><br />
        
        <label>Start Date: </label>
        <input type="text" name="StartDate" readonly="readonly" value="<%=rs.getString("StartDate")%>" /><br />
        
        <label>Hourly Rate: </label>
        <input type="text" name="HourlyRate" <% if(session.getAttribute("Access").equals("CustomerRep")) { %> readonly="readonly" <%}%> value="<%=rs.getInt("HourlyRate")%>" /><br />
        
        <input type="button" value="Update Info" onclick="return button_updateInfo()" />&nbsp;
        <input type="button" value="Cancel" onclick="window.location='gohome.jsp'"/>
        </form>
    </td>
    </tr>
   </table>
        <% 
                }
        catch(Exception e) { e.printStackTrace(); }
        finally
        {
            try {
            conn.close(); }
            catch(Exception e) {}
        }
        %>
    </body>
</html>
